<template>
  <div class="flex-r" style="width: 100%">
    <input placeholder="请输入图形验证码" class="input" v-model="imgCode"/><img :src="codeImgUrl" class="img-code" @click="clickImg">
  </div>
</template>

<script type="text/ecmascript-6">
  import Public from '@/assets/js/public';

  export default {
    /** kebab-case */
    name: 'Cell-img-verification',

    data() {
      return {
        imgCode: null
      };
    },
    /** 在声明 prop 的时候，其命名应该始终使用 camelCase，而在模板和 JSX 中应该始终使用 kebab-case。
     String/Number/Boolean/Function/Object/Array/Symbol */
    props: {
      codeImgUrl: {
        required: true,
        type: String
      }
    },

    components: {},

    methods: {
      getIcon(icon) {
        return Public.ossImg + icon + '.svg';
      },
      clickImg() {
        this.$emit('imgClicked');
      }
    },
    computed: {},
    watch: {
      imgCode() {
        this.$emit('getInput', this.imgCode);
      }
    }
  };
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
  @import "../../assets/stylus/main.styl";
  .flex-r
    flex-x()

  .flex-c
    flex-y()

  .center
    flex-center()

  .divider
    divider()

  .space
    space()

  .input
    flex 1
    height cell-height
    word-big()
    padding-left 10px

  .img-code
    height cell-height

  ::-webkit-input-placeholder
    word-vw(16px, third-ash)

  :-moz-placeholder
    word-vw(16px, third-ash)

  ::-moz-placeholder
    word-vw(16px, third-ash)

  :-ms-input-placeholder
    word-vw(16px, third-ash)
</style>
